home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 12 / q12.d81 / t.zero page 12 < prev    next >
Text File  |  2022-08-28  |  10KB  |  212 lines

  1.                  ZERO PAGE: MOVING FROM THE C-64 TO THE C-128
  2.  
  3.                      By Barbara H. Schulak and Jon Mattson
  4.  
  5.      If you have owned a C-64 and then upgraded to a C-128, you will
  6. certainly appreciate BASIC 7.0's increased vocabulary, not to mention the
  7. improved graphics and sprite tools.  The architecture of each machine is
  8. similar, especially in the case of the 40-column screen; however, some
  9. things are different and/or not clearly explained in the various
  10. publications about the C-128.  As we discover these little "trade secrets",
  11. we usually jot them down for future reference.  Now we would like to pass
  12. some of them along to you.  They are in no particular order nor carry a
  13. theme, but are merely 'ramblings'.
  14.  
  15.      First, the function keys.  They come with preset definitions, of
  16. course, which may be changed by the KEY command.  There will be times,
  17. however, when you want to change them to the normal CHR$ values so that you
  18. can use them in a program.  One solution is to go KEY1,CHR$(131), etc. but
  19. an easier method is to POKE 828,183.  To restore the normal definitions,
  20. POKE 828,173.  Another problem is that the F1-F8 keys can be changed by
  21. using KEY, but the HELP and SHIFT/RUN/STOP definitions are not so easy to
  22. access.  To change these definitions...
  23.  
  24.   SYS 24812,,9,,,"DEFINITION"
  25.  
  26.   SYS 24812,,8,,,"DEFINITION"
  27.  
  28.      There are also a few more keys on the keyboard.  How does one detect
  29. these in a program?  Location 211 is the shift key status flag but also
  30. indicates if the Commodore, CTRL, ALT or CAPS LOCK key has been pressed. 
  31. Each bit corresponds to a key so that the values are additive:
  32.  
  33.    SHIFT         Bit 0 (1)
  34.    Commodore     Bit 1 (2)
  35.    CONTROL       Bit 2 (4)
  36.    ALT           Bit 3 (8)
  37.    CAPS LOCK     Bit 4 (16)
  38.  
  39. Therefore, the code to wait for the ALT key to be pressed would be...
  40.  
  41.    10 IF PEEK(211)<>8 THEN 10
  42.  
  43.      Likewise the ESC, TAB, HELP, LINEFEED, NO SCROLL, upper cursor keys and
  44. keypad can be detected by PEEKing location 212.  The appropriate values for
  45. these can be found in most reference guides.
  46.  
  47.      And what of the 40/80 display switch?  To check the status of this key,
  48. use...
  49.  
  50.    X=PEEK(54533) AND 128
  51.  
  52. If X=0, the key is up (40-column); if X=128, then the switch is down
  53. (80-column).  Similarly, you can PEEK(215) to see if you are in 40-column
  54. mode (0) or in 80-column mode (128).
  55.  
  56.      You may have encountered a few difficulties with the CHAR command. 
  57. When trying to use the hires screen with the lower case font, simply
  58. switching character sets does not work.  The solution to this problem is to
  59. include a CHR$(14) command in your string as follows:
  60.  
  61.    CHAR,X,Y,CHR$(14)+A$
  62.  
  63.      The CHAR command also does not function properly on the 80-column
  64. screen if you move the start of BASIC to $4000 by using the usual
  65. GRAPHIC1:GRAPHIC5 syntax (to use the underlying memory for ML modules or
  66. graphics, for example).  It prints to the hires screen instead, since that
  67. is the screen the VIC chip is currently "watching".  In fact, if you switch
  68. your monitor to 40-columns while the computer still thinks it is using 80,
  69. you will notice that the hires screen, not the text screen, is visible.  The
  70. solution to this is simple: GRAPHIC1:GRAPHIC0:GRAPHIC5 will point the VIC
  71. chip in the right direction.
  72.  
  73.      Of course, no discussion of the 128 would be complete without
  74. mentioning the peculiarities of the 80-column screen.  Here are a few
  75. examples of things that we have learned...
  76.  
  77.    1] To POKE a value to a VDC register:  SYS 52684,value,register
  78.  
  79.    2] To PEEK a VDC register:  SYS 52698,,register:RREG A
  80.  
  81.    3] To turn on the cursor:  SYS 52684,192,10
  82.  
  83.    4] To turn off the cursor:  SYS 52684,160,10
  84.  
  85.    5] To restore the normal Commodore character sets (after using a custom
  86. font, for example):  SYS 65378 (or 52748)
  87.  
  88.    6] When altering color memory directly, the required values are not the
  89. same as those used with the 40-column screen, nor are they the values
  90. inaccurately listed in most reference sources (including the Programmer's
  91. Reference Guide).  The actual values are:
  92.  
  93.     0 - Black           5 - Light Green      10 - Dark Purple
  94.     1 - Dark Grey       6 - Dark Cyan        11 - Light Purple
  95.     2 - Dark Blue       7 - Light Cyan       12 - Dark Yellow
  96.     3 - Light Blue      8 - Dark Red         13 - Light Yellow
  97.     4 - Dark Green      9 - Light Red        14 - Light Grey
  98.                                                  15 - White
  99.  
  100.    7] 'Color memory' is actually a misnomer on the 80-column screen: the
  101. term 'attribute memory' is actually more correct.  The reason for this is
  102. that each byte of attribute memory uses the first four bits for color as
  103. usual (see #6) but also uses the last four bits, as follows:
  104.  
  105.     4 (16)  - Blink
  106.     5 (32)  - Underline
  107.     6 (64)  - Reverse
  108.     7 (128) - Alternate set
  109.  
  110. Bit 7 is especially important, since it allows the VDC to display two
  111. character sets on the screen at the same time, for a total of 512
  112. characters.  However...
  113.  
  114.    8] The reverse attribute is NOT the same as reverse character mode. 
  115. Choosing the reverse attribute for a character does a literal inversion of
  116. the shape in question rather than just replacing it with the character's
  117. screen code + 128.  An example should clarify this.
  118.  
  119.       Normally, when you print a reversed 'A' to the screen, it has a screen
  120. code of 129 (128 higher than the usual value of 1).  If you alter the font
  121. so that character number 129 looks like a bug, you will get a bug every time
  122. you print a reversed 'A'.  HOWEVER, if you use the reverse attribute (bit 6)
  123. instead, you can make a normal 'A' look like a reversed 'A' and your bug
  124. look like a reversed bug!  If you think about this for a moment, you will
  125. realize an important implication: by manipulating attribute memory directly
  126. (for example, with CONTROL80's POST command), you can have revsersed
  127. characters without using the second half of your font at all; instead, it
  128. can be redefined in any way you choose.  In effect, you have, not 512
  129. characters to work with, but 1024 -- the usual two full characters sets of
  130. 256 each, plus the reversed versions of these!
  131.  
  132.      By the way, point #2 brings up another interesting near-unknown about
  133. the 128.  Although many reference guides do not mention it, the 128 has
  134. another new command called RREG.  It is mainly for use with the SYS command
  135. and machine language routines since it reads the A,X,Y and Status registers
  136. (respectively) and puts them into variables.  For example,
  137.  
  138.    BANK 15:SYS 65517:RREG SW,WW,WH
  139.  
  140. allows you to determine the size of the current screen window.  SW will
  141. contain the full screen width, WW will contain the window width, and WH will
  142. contain the window height.
  143.  
  144.      Another tip for machine language programmers: JSR 65357 (or SYS 65357
  145. in BASIC) works the same as the GO64 command, allowing you to enter C-64
  146. mode.  Remember that this is a one-way trip!
  147.  
  148.      Finally, here are a few useful PEEKs and POKEs, along with their C-64
  149. equivalents.  Some of those already mentioned are included here again for
  150. your convenience.  Notice, in particular, that clearing the keyboard buffer
  151. (POKE 208,0) does NOT clear any pending function keys.  For this, you must
  152. use POKE 209,0.  This is also a good way to keep the buffer clear of
  153. meaningless input from joystick #1: you have probably noticed that the fire
  154. button acts as F8 and calls up the machine language monitor while the
  155. function keys have their default definitions.
  156.  
  157.    FUNCTION                       C-128               C-64
  158.  
  159.    LIST: Disable                   POKE 775,139       POKE 775,191
  160.          Enable                    POKE 775,81        POKE 775,167
  161.    LIST Line #s: Disable           POKE 24,37         POKE 22,35
  162.                  Enable            POKE 24,27         POKE 22,25
  163.    LOAD: Disable                   POKE 816,0         POKE 816,157
  164.          Enable                    POKE 816,108       POKE 816,165
  165.    SAVE: Disable                   POKE 818,180       POKE 819,246
  166.          Enable                    POKE 818,78        POKE 819,245
  167.    RUN/STOP Key: Disable           POKE 808,100       POKE 808,239
  168.          Enable                    POKE 808,110       POKE 808,237
  169.    RESTORE Key: Disable